package com.hclc.entity.model.series;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author: hef
 * 序列化LocalTime
 * @Date: Create in 11:14 2020-02-29
 */
public class CustomLocalTimeSerializer extends JsonSerializer<LocalTime> {
    @Override
    public void serialize(LocalTime localTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm:ss");
        String time = df.format(localTime);
        jsonGenerator.writeString(time);
    }
}
